<!DOCTYPE html>
<html lang="en">
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>系统管理首页</title>
  <link rel="stylesheet" href="../css/bootstrap.css">
  <style>
    li{list-style: none;}
    a:visited{color: white}

  </style>
</head>
<body>
<!--顶部、主体-->
<div class="container">
  <div class="row text-center bg-black text-white">
    <div class="col-2">
      <img src="../img/logo.png" alt="" width="50%">
    </div>
    <div class="col-8">致欢迎词</div>
    <div class="col-2">
      <span>当前用户:</span>
      <span th:text="${username}"></span>
      <span><a href="/logout">退出</a></span>
    </div>
  </div>
  <div class="row" style="min-height: 400px">
    <div class="col-2 bg-black text-white pt-5">
      <li class="m-2">
        <a href="/main">管理首页</a>
      </li>
      <li class="m-2">
        <a href="/goods/goodsList">商品模块</a>
      </li>
      <li class="m-2">
        <a href="/supplier">供应商模块</a>
      </li>
      <li class="m-2"><a href="/user">管理用户模块</a></li>
    </div>
    <div class="col-10 pt-2">
      <!--        update内容区-->
      <p>更新该商品数据</p>

      <div class="form-control">
        <label for="">序号</label>
        <input type="text" name="id" id="Id" th:value="${data.id}" disabled="disabled">
      </div>
      <div class="form-control">
        <label for="">货物名称</label>
        <input type="text" name="name" id="name" th:value="${data.name}">
      </div>
      <div class="form-control">
        <label for="">价格</label>
        <input type="text" name="price" id="price" th:value="${data.price}">
      </div>
      <div class="form-control">
        <label for="">货物数量</label>
        <input type="text" name="quantity" id="quantity" th:value="${data.quantity}">
      </div>
      <div class="form-control">
        <label for="">货物类型</label>
        <input type="text" name="category" id="category" th:value="${data.category}">
      </div>
      <div class="form-control">
        <label for="">货物数量</label>
        <input type="text" name="supplier" id="supplier" th:value="${data.supplier}">
      </div>
      <div class="form-control">
        <button class="btn btn-danger" id="btnUpdate">更新</button>>
      </div>

    </div>
  </div>
  <div class="footer text-center bg-black text-white">
    @2023-2028，版本所有，违者必究
  </div>
</div>
</body>
</html>
<script src="../js/jquery.js"></script>
<script>
  $('#btnUpdate').click(function(){
    var flag = confirm("确认提交更新?");
    if(flag==true){
      $.post("/api/goodsUpdateProcess",{"id":$('#Id').val(),"name":$('#name').val(),"price":$('#price').val(),
        "quantity":$('#quantity').val(),"category":$('#category').val(),"supplier":$('#supplier').val()
      },function(res){
        if(res==1){
          alert("更新ok");
          location.href="/goods/goodsList";
        }else{
          alert("更新失败!");
        }
      })
    }
  })

</script>